package com.ht.shop.listeners;

import com.ht.shop.utils.ExcutorsUtils;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.util.concurrent.Executors;

@WebListener
public class ApplicationContextListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //程序启动的时候创建长度为十的线程池
//        System.out.println("11111");
        ExcutorsUtils.setExecutorService(Executors.newScheduledThreadPool(10));
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        //销毁线程池
        ExcutorsUtils.shutdown();
    }
}
